package de.fhaugsburg.games.boardgames.scrabble;

import java.util.ArrayList;
import java.util.List;

import de.fhaugsburg.games.boardgames.Player;
import de.fhaugsburg.games.boardgames.exceptions.GameException;
import de.fhaugsburg.games.boardgames.scrabble.exceptions.NotAllowedLetterException;
/**
 * this class extends the player class to manage the different letters for each scrabble player.
 * @author r4smus
 *
 */
public class ScrabblePlayer extends Player {
/**
 * the myPieces attribute contains the 7 letters which can the player use in a scrabble game.	
 */
	private List<LetterPiece> myPieces = new ArrayList<LetterPiece>(7);

	public ScrabblePlayer(String name) {
		super(name);
		// TODO Auto-generated constructor stub
	}
/**
 * receive one specific piece and add it to myPieces.	
 * @param piece
 */
	public void receive(LetterPiece piece){
		myPieces.add(piece);
	}
/**
 * receive all 7 pieces and add it to myPieces.
 * @param pieceList
 */
	public void receiveAll(List<LetterPiece> pieceList){
		myPieces.addAll(pieceList);
	}
/**
 * remove one specific piece from myPieces.	
 * @param piece
 * @throws GameException 
 */
	public void giveAway (LetterPiece piece) throws GameException{
		if(myPieces.contains(piece))
		myPieces.remove(piece);
		else
			throw new NotAllowedLetterException(piece);
	}
	public List<LetterPiece> getAllPieces(){
		return myPieces;
	}

}
